

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>FS 卷和子卷 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="CephFS 配额管理" href="../quota/" />
    <link rel="prev" title="分布式文件系统之上的应用程序最佳实践" href="../app-best-practices/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">FS 卷和子卷</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/fs-volumes.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id4">管理</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../createfs/"> 创建 CephFS 文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../administration/"> 管理命令</a></li>
<li class="toctree-l3"><a class="reference internal" href="../multifs/"> 创建多个文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../add-remove-mds/"> 配备、增加、删除 MDS</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/">术语</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds">MDS 守护进程的引用</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#id3">故障切换的管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#standby-replay">热备（ standby-replay ）的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds-join-fs">配置 MDS 与文件系统的亲和性</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cache-configuration/"> MDS 缓存配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mds-config-ref/"> MDS 配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/ceph-mds/"> ceph-mds 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../nfs/"> 通过 NFS 导出</a></li>
<li class="toctree-l3"><a class="reference internal" href="../app-best-practices/"> 应用最佳实践</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> FS 卷和子卷</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">必备条件</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">FS 卷</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">FS 子卷组</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">FS 子卷</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id28">克隆快照</a></li>
<li class="toctree-l4"><a class="reference internal" href="#subvol-pinning">锁定子卷和子卷组</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id31">规范化和大小写敏感</a></li>
<li class="toctree-l4"><a class="reference internal" href="#subvolume-quiesce">子卷静默（ subvolume quiesce ）</a></li>
<li class="toctree-l4"><a class="reference internal" href="#volumes">禁用 volumes 插件</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../quota/"> CephFS 配额管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../health-messages/"> 健康消息</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/">升级 MDS 集群</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/#firefly-jewel">升级比 Firefly 老的文件系统，需过 Jewel 这个槛</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-top/"> CephFS Top 工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../snap-schedule/"> 定时快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-mirroring/"> CephFS 快照镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="../purge-queue/"> 清理队列</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="fs">
<span id="fs-volumes-and-subvolumes"></span><h1>FS 卷和子卷<a class="headerlink" href="#fs" title="Permalink to this heading"></a></h1>
<p><a class="reference internal" href="../../glossary/#term-11"><span class="xref std std-term">Ceph 管理器</span></a>守护进程（ ceph-mgr ）的 volumes 模块为
CephFS 导出提供了单一可信来源。 OpenStack 共享文件系统服务
（ <a class="reference external" href="https://github.com/openstack/manila">manila</a> ）和 Ceph 容器存储接口（ <a class="reference external" href="https://github.com/ceph/ceph-csi">CSI</a> ）存储管理员可以用 ceph-mgr <code class="docutils literal notranslate"><span class="pre">volumes</span></code> 模块提供的通用 CLI 来管理 CephFS 导出。</p>
<p>ceph-mgr <code class="docutils literal notranslate"><span class="pre">volumes</span></code> 模块实现了以下的文件系统导出抽象层：</p>
<ul class="simple">
<li><p>FS volumes （ FS 卷）， CephFS 文件系统的抽象</p></li>
<li><p>FS subvolume groups （ FS 子卷组），在 FS 子卷之上的、目录级别的抽象。
用于对子卷集合应用策略（例如 <a class="reference internal" href="../file-layouts/"><span class="doc">文件布局</span></a> ）。</p></li>
<li><p>FS subvolumes （ FS 子卷）， CephFS 独立目录树的抽象。</p></li>
</ul>
<p>导出抽象的可能应用场景：</p>
<ul class="simple">
<li><p>FS 子卷，用于 Manila 共享或 CSI 卷；</p></li>
<li><p>FS 子卷组，用作 Manila 共享组</p></li>
</ul>
<section id="id1">
<h2>必备条件<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<ul>
<li><p>Nautilus (14.2.x) 或更高版本</p></li>
<li><p>Cephx 客户端用户（见 <a class="reference internal" href="../../rados/operations/user-management/"><span class="doc">用户管理</span></a> ）
至少得拥有下列能力：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="s1">&#39;allow r&#39;</span>
<span class="n">mgr</span> <span class="s1">&#39;allow rw&#39;</span>
</pre></div>
</div>
</li>
</ul>
</section>
<section id="id2">
<h2>FS 卷<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>执行下列命令，创建一个卷：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "# ";
}
</style><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>volume<span class="w"> </span>create<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span><span class="o">[</span>placement<span class="o">]</span></span>
</pre></div></div><p>这将创建一个 CephFS 文件系统及其数据和元数据存储池。
此命令还能用 Ceph 管理器的 orchestrator 模块（如 Rook）
为文件系统部署 MDS 守护进程。参阅 <a class="reference internal" href="../../mgr/orchestrator/"><span class="doc">Orchestrator CLI</span></a> 。</p>
<p><code class="docutils literal notranslate"><span class="pre">&lt;vol_name&gt;</span></code> 是卷名（任意字符串）。
<code class="docutils literal notranslate"><span class="pre">[placement]</span></code> 是一个可选字符串，
用于指定 MDS 的 <a class="reference internal" href="../../cephadm/services/#orchestrator-cli-placement-spec"><span class="std std-ref">Daemon Placement</span></a> 。
另请参阅 <a class="reference internal" href="../../cephadm/services/mds/#orchestrator-cli-cephfs"><span class="std std-ref">Deploy CephFS</span></a> ，了解有关归置的更多示例。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>系统不支持通过卷接口、用一个 YAML 文件指定归置策略。</p>
</div>
<p>要删除一个卷，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>volume<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span><span class="o">[</span>--yes-i-really-mean-it<span class="o">]</span></span>
</pre></div></div><p>此命令用于删除文件系统及其数据和元数据存储池。
如果已启用 Ceph 管理器 orchestrator 模块，还会尝试删除 MDS 守护进程。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>卷删除后，如果在同一集群上创建了新文件系统且正在使用子卷接口，我们建议重启 <cite>ceph-mgr</cite> 。
详情见 <a class="reference external" href="https://tracker.ceph.com/issues/49605#note-5">https://tracker.ceph.com/issues/49605#note-5</a> 。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果 Ceph 管理器模块 snap-schedule 正用于某个卷，
而该卷被删除了，那么 snap-schedule Ceph 管理器模块将继续保持对旧存储池的引用。
这会导致 snap-schedule Ceph 管理器模块发生故障并记录错误。
要纠正这种情况，我们建议，
删除卷后重启 snap-schedule Ceph 管理器模块。
如果故障依旧，我们建议重启 <cite>ceph-mgr</cite> 。</p>
</div>
<p>罗列卷，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>volume<span class="w"> </span>ls</span>
</pre></div></div><p>重命名卷，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>volume<span class="w"> </span>rename<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;new_vol_name&gt;<span class="w"> </span><span class="o">[</span>--yes-i-really-mean-it<span class="o">]</span></span>
</pre></div></div><p>重命名卷是昂贵（繁杂）的操作，需要以下必备条件：</p>
<ul class="simple">
<li><p>重命名 orchestrator 托管的 MDS 服务，使其与 <code class="docutils literal notranslate"><span class="pre">&lt;new_vol_name&gt;</span></code> 匹配。
这需要以 <code class="docutils literal notranslate"><span class="pre">&lt;new_vol_name&gt;</span></code> 启动 MDS 服务，
并关闭 <code class="docutils literal notranslate"><span class="pre">&lt;vol_name&gt;</span></code> 的 MDS 服务。</p></li>
<li><p>重命名文件系统，把 <code class="docutils literal notranslate"><span class="pre">&lt;vol_name&gt;</span></code> 改成 <code class="docutils literal notranslate"><span class="pre">&lt;new_vol_name&gt;</span></code> 。</p></li>
<li><p>更改此文件系统数据存储池和元数据存储池上的应用程序标签，
改成 <code class="docutils literal notranslate"><span class="pre">&lt;new_vol_name&gt;</span></code> 。</p></li>
<li><p>重命名此文件系统的元数据和数据存储池。</p></li>
</ul>
<p>已经授权给 <code class="docutils literal notranslate"><span class="pre">&lt;vol_name&gt;</span></code> 的 CephX ID ，必须重新授权给 <code class="docutils literal notranslate"><span class="pre">&lt;new_vol_name&gt;</span></code> 。
使用这些 ID 的客户端，它们的所有正在进行的操作可能会中断。
确保在这个卷上禁用镜像功能。</p>
<p>要提取 CephFS 卷的信息，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>volume<span class="w"> </span>info<span class="w"> </span>vol_name<span class="w"> </span><span class="o">[</span>--human_readable<span class="o">]</span></span>
</pre></div></div><p>加上 <code class="docutils literal notranslate"><span class="pre">--human_readable</span></code> 选项，会以 KB/MB/GB 单位显示存储池的已用和可用空间。</p>
<p>输出是 JSON 格式，会包含下列字段：</p>
<ul class="simple">
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">pools</span></code>: 数据和元数据存储池属性</dt><dd><ul>
<li><p><code class="docutils literal notranslate"><span class="pre">avail</span></code>: 可用的空闲空间，单位是字节</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">used</span></code>: 已消耗的存储量，单位是字节</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">name</span></code>: 存储池名字</p></li>
</ul>
</dd>
</dl>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">mon_addrs</span></code>: Ceph 监视器地址列表</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">used_size</span></code>: 当前已经用掉的 CephFS 卷大小，单位是字节</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pending_subvolume_deletions</span></code>: 等待被删除的子卷数量</p></li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">volume</span> <span class="pre">info</span></code> 命令的输出样本：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>volume<span class="w"> </span>info<span class="w"> </span>vol_name</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;mon_addrs&quot;</span><span class="p">:</span> <span class="p">[</span>
        <span class="s2">&quot;192.168.1.7:40977&quot;</span>
    <span class="p">],</span>
    <span class="s2">&quot;pending_subvolume_deletions&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;pools&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;data&quot;</span><span class="p">:</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s2">&quot;avail&quot;</span><span class="p">:</span> <span class="mi">106288709632</span><span class="p">,</span>
                <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;cephfs.vol_name.data&quot;</span><span class="p">,</span>
                <span class="s2">&quot;used&quot;</span><span class="p">:</span> <span class="mi">4096</span>
            <span class="p">}</span>
        <span class="p">],</span>
        <span class="s2">&quot;metadata&quot;</span><span class="p">:</span> <span class="p">[</span>
            <span class="p">{</span>
                <span class="s2">&quot;avail&quot;</span><span class="p">:</span> <span class="mi">106288709632</span><span class="p">,</span>
                <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;cephfs.vol_name.meta&quot;</span><span class="p">,</span>
                <span class="s2">&quot;used&quot;</span><span class="p">:</span> <span class="mi">155648</span>
            <span class="p">}</span>
        <span class="p">]</span>
    <span class="p">},</span>
    <span class="s2">&quot;used_size&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
</section>
<section id="id3">
<h2>FS 子卷组<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>创建一个子卷组，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>create<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span><span class="o">[</span>--size<span class="w"> </span>&lt;size_in_bytes&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--pool_layout<span class="w"> </span>&lt;data_pool_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--uid<span class="w"> </span>&lt;uid&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--gid<span class="w"> </span>&lt;gid&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--mode<span class="w"> </span>&lt;octal_mode&gt;<span class="o">]</span></span>
</pre></div></div><p>即使要创建的子卷组已经存在，这个命令也会成功。</p>
<p>创建子卷组时，可以指定其数据存储池布局
（参阅 <a class="reference internal" href="../file-layouts/"><span class="doc">文件布局</span></a> ）、 uid 、 gid 、
以八进制数字表示的文件模式、以及按字节计算的大小。
子卷组的大小可设置配额来指定（参阅 <a class="reference internal" href="../quota/"><span class="doc">CephFS 配额管理</span></a> ）。
默认情况下，创建的子卷组：文件权限位是八进制的 <code class="docutils literal notranslate"><span class="pre">755</span></code> 、
uid <code class="docutils literal notranslate"><span class="pre">0</span></code> 、 gid <code class="docutils literal notranslate"><span class="pre">0</span></code> 、数据存储池布局继承其父目录的。</p>
<p>删除子卷组，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span><span class="o">[</span>--force<span class="o">]</span></span>
</pre></div></div><p>如果子卷组不为空或不存在，则删除子卷组会失败。
当命令的参数是一个不存在的子卷组时，
<code class="docutils literal notranslate"><span class="pre">--force</span></code> 标志可以让命令成功执行。</p>
<p>获取子卷组的绝对路径，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>getpath<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;</span>
</pre></div></div><p>罗列子卷组，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>ls<span class="w"> </span>&lt;vol_name&gt;</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>子卷组的快照功能在主线 CephFS 里不再支持了，
现有的组快照仍然能罗列、删除。</p>
</div>
<p>提取一个子卷组的元数据，
执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>info<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;</span>
</pre></div></div><p>输出是 JSON 格式，包含下列字段：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">atime</span></code>: 子卷组路径的访问时间，
格式是 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mtime</span></code>: 子卷组路径的最近修改时间，
格式是 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ctime</span></code>: 子卷组路径的最近更改时间，
格式是 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">uid</span></code>: 子卷组路径的 uid</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">gid</span></code>: 子卷组路径的 gid</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mode</span></code>: 子卷组路径的权限位（ mode ）</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mon_addrs</span></code>: 监视器地址列表</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">bytes_pcent</span></code>: 如果设置了配额，这里就显示已用配额的百分比；否则显示 “undefined”</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">bytes_quota</span></code>: 如果设置了配额，这里就显示配额大小，字节数；否则显示 “infinite”</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">bytes_used</span></code>: 当前用掉的子卷组大小，字节数</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">created_at</span></code>: 子卷组的创建时间，按格式 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">data_pool</span></code>: 子卷组所属的数据存储池</p></li>
</ul>
<p>检查指定的子卷组是否存在，
执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>exist<span class="w"> </span>&lt;vol_name&gt;</span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">exist</span></code> 命令会输出：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">subvolumegroup</span> <span class="pre">exists</span></code>: 如果它存在</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">no</span> <span class="pre">subvolumegroup</span> <span class="pre">exists</span></code>: 如果它不存在</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>此命令检查的是自定义组是否存在，
而不是默认组是否存在。
只有子卷组存在性的检查不足以确认此卷是否为空，
还必须检查子卷是否存在，因为默认组里可能有子卷。</p>
</div>
<p>改变一个子卷组的大小，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>resize<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span>&lt;new_size&gt;<span class="w"> </span><span class="o">[</span>--no_shrink<span class="o">]</span></span>
</pre></div></div><p>此命令用于调整子卷组配额的大小，指定的新尺寸是 <code class="docutils literal notranslate"><span class="pre">new_size</span></code> 。
<code class="docutils literal notranslate"><span class="pre">--no_shrink</span></code> 标志可防止子卷组缩小，
缩到低于当前已用大小。</p>
<p>子卷组的大小可以调整为无限大，
传入 <code class="docutils literal notranslate"><span class="pre">inf</span></code> 或 <code class="docutils literal notranslate"><span class="pre">infinite</span></code> 作为 <code class="docutils literal notranslate"><span class="pre">new_size</span></code> 。</p>
<p>删除子卷组的快照，
执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>snapshot<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span><span class="o">[</span>--force<span class="o">]</span></span>
</pre></div></div><p>快照不存在时，此命令会失败，
加上 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 选项命令就会成功。</p>
<p>罗列一个子卷组的快照，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>snapshot<span class="w"> </span>ls<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;</span>
</pre></div></div></section>
<section id="id4">
<h2>FS 子卷<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<section id="id5">
<h3>创建子卷<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h3>
<p>创建子卷，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>create<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--size<span class="w"> </span>&lt;size_in_bytes&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--pool_layout<span class="w"> </span>&lt;data_pool_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--uid<span class="w"> </span>&lt;uid&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--gid<span class="w"> </span>&lt;gid&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--mode<span class="w"> </span>&lt;octal_mode&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--namespace-isolated<span class="o">]</span><span class="w"> </span><span class="o">[</span>--earmark<span class="w"> </span>&lt;earmark&gt;<span class="o">]</span></span>
</pre></div></div><p>即使要创建的子卷已经存在，此命令也会返回成功。</p>
<p>创建子卷时，可以指定它的子卷组、数据存储池布局、
uid 、 gid 、八进制的文件模式以及以字节表示的大小。
子卷的大小是用配额来指定的（参阅 <a class="reference internal" href="../quota/"><span class="doc">CephFS 配额管理</span></a> ）。
可以在单独的 RADOS 命名空间中创建子卷，加 <code class="docutils literal notranslate"><span class="pre">--namespace-isolated</span></code> 选项。
默认情况下，子卷会在默认子卷组内创建，
八进制文件模式为 <code class="docutils literal notranslate"><span class="pre">755</span></code> ， uid 继承其子卷组的， gid 继承子卷组的，
数据存储池布局继承其父目录的、且没有大小限制。
你还可以用 <code class="docutils literal notranslate"><span class="pre">--earmark</span></code> 选项为子卷分配一个 earmark 。
earmark 是个唯一标识符，用于标记特定用途的子卷，
如 NFS 或 SMB 服务。默认不设置 earmark ，
这样就允许根据管理需要灵活分配。
空字符串（ “” ）可用于删除子卷上现有的所有标记。</p>
<p>earmark 机制能确保正确地标记和管理子卷，
有助于避免冲突，并确保每个子卷都与预期的服务或用例相关联。</p>
</section>
<section id="earmark">
<h3>可用的 earmark<a class="headerlink" href="#earmark" title="Permalink to this heading"></a></h3>
<ul class="simple">
<li><dl class="simple">
<dt><strong>对于 NFS:</strong></dt><dd><ul>
<li><p>可用的 earmark 格式是顶级范围（ top-level scope ）： <code class="docutils literal notranslate"><span class="pre">'nfs'</span></code> 。</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>对于 SMB:</strong></dt><dd><ul>
<li><dl class="simple">
<dt>可用的 earmark 格式有：</dt><dd><ul>
<li><p>顶级范围： <code class="docutils literal notranslate"><span class="pre">'smb'</span></code> 。</p></li>
<li><p>顶级范围、加上模块内级别范围： <code class="docutils literal notranslate"><span class="pre">'smb.cluster.{cluster_id}'</span></code> ，
其中， <code class="docutils literal notranslate"><span class="pre">cluster_id</span></code> 是唯一标识集群的短字符串。</p></li>
<li><p>不含模块内范围，实例： <code class="docutils literal notranslate"><span class="pre">smb</span></code></p></li>
<li><p>包含模块内范围，实例： <code class="docutils literal notranslate"><span class="pre">smb.cluster.cluster_1</span></code></p></li>
</ul>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
</li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果要把 earmark 从一个范围改成另一个（比如 nfs 改为 smb ，或反过来），
注意与先前范围相关的用户权限和 ACL 可能仍然有效。
确保根据需要更新必要的权限，以维持正确的访问控制。</p>
</div>
</section>
<section id="id6">
<h3>删除子卷<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h3>
<p>删除子卷，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--force<span class="o">]</span><span class="w"> </span><span class="o">[</span>--retain-snapshots<span class="o">]</span></span>
</pre></div></div><p>此命令将删除子卷及其内容，分两步完成。
首先，把子卷移至垃圾文件夹；其次，异步地清除垃圾文件夹中的内容。</p>
<p>如果子卷有快照或不存在，子卷移除将失败。
加 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 选项可以让 “non-existent subvolume remove” 的命令成功。</p>
<p>要在删除子卷的同时保留该子卷的快照，用 <code class="docutils literal notranslate"><span class="pre">--retain-snapshots</span></code> 标志。
如果保留与指定子卷相关联的快照，
那么所有与保留的快照不相干的操作，都会把这个子卷视为空卷。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>可以用 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">fs</span> <span class="pre">subvolume</span> <span class="pre">create</span></code> 命令重新创建保留了快照的子卷。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>保留的快照可用作重新创建子卷、或克隆新子卷的克隆源。</p>
</div>
</section>
<section id="id7">
<h3>改变子卷大小<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h3>
<p>更改子卷大小，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>resize<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;new_size&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--no_shrink<span class="o">]</span></span>
</pre></div></div><p>此命令用于调整子卷配额的大小，新尺寸是 <code class="docutils literal notranslate"><span class="pre">new_size</span></code> 。
<code class="docutils literal notranslate"><span class="pre">--no_shrink</span></code> 标志可防止子卷缩小到低于当前子卷的“used size （已用大小）”。</p>
<p>子卷大小可以调整为逻辑上无限大（却是稀疏的），
传入 <code class="docutils literal notranslate"><span class="pre">inf</span></code> 或 <code class="docutils literal notranslate"><span class="pre">infinite</span></code> 作为 <code class="docutils literal notranslate"><span class="pre">&lt;new_size&gt;</span></code> 。</p>
</section>
<section id="cephfs-id">
<h3>授予 CephFS 认证 ID<a class="headerlink" href="#cephfs-id" title="Permalink to this heading"></a></h3>
<p>授予 CephX 认证 ID ，这将授予对文件系统子卷的读/读写访问权限，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>authorize<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;sub_name&gt;<span class="w"> </span>&lt;auth_id&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="o">=</span>&lt;group_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--access_level<span class="o">=</span>&lt;access_level&gt;<span class="o">]</span></span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">&lt;access_level&gt;</span></code> 选项的值可以是 <code class="docutils literal notranslate"><span class="pre">r</span></code> 或 <code class="docutils literal notranslate"><span class="pre">rw</span></code> 。</p>
</section>
<section id="cephx-id">
<h3>取消授予的 CephX 认证 ID<a class="headerlink" href="#cephx-id" title="Permalink to this heading"></a></h3>
<p>取消授予的 CephX 认证 ID ，这将删除对文件系统子卷的读/读写访问权限，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>deauthorize<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;sub_name&gt;<span class="w"> </span>&lt;auth_id&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="o">=</span>&lt;group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id8">
<h3>罗列 CephX 认证 ID<a class="headerlink" href="#id8" title="Permalink to this heading"></a></h3>
<p>罗列 CephX 认证 ID 被授予的文件系统子卷访问权限，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>authorized_list<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;sub_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="o">=</span>&lt;group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="auth-id">
<h3>驱逐文件系统客户端（ auth ID ）<a class="headerlink" href="#auth-id" title="Permalink to this heading"></a></h3>
<p>驱逐用认证 ID 和挂载的子卷标识的文件系统客户端，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>evict<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;sub_name&gt;<span class="w"> </span>&lt;auth_id&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="o">=</span>&lt;group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id9">
<h3>提取一个子卷的绝对路径<a class="headerlink" href="#id9" title="Permalink to this heading"></a></h3>
<p>提取一个子卷的绝对路径，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>getpath<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id10">
<h3>提取一个子卷的信息<a class="headerlink" href="#id10" title="Permalink to this heading"></a></h3>
<p>提取一个子卷的信息，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>info<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div><p>其输出是 JSON 格式，包含下列字段。</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">atime</span></code>: 子卷路径的访问时间，按格式 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mtime</span></code>: 子卷路径的修改时间，按格式 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ctime</span></code>: 子卷路径的变更时间，按格式 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">uid</span></code>: 子卷路径的 uid</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">gid</span></code>: 子卷路径的 gid</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mode</span></code>: 子卷路径的权限位</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mon_addrs</span></code>: 监视器地址列表</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">bytes_pcent</span></code>: 如果设置了配额，这里就显示已用配额的百分比；
否则显示 <code class="docutils literal notranslate"><span class="pre">undefined</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">bytes_quota</span></code>: 如果设置了配额，这里就显示配额大小，字节数；
否则显示 <code class="docutils literal notranslate"><span class="pre">infinite</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">bytes_used</span></code>: 当前用掉的子卷组大小，字节数</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">created_at</span></code>: 子卷组的创建时间，按格式
<code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">data_pool</span></code>: 子卷组所属的数据存储池</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">path</span></code>: 子卷的绝对路径</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">type</span></code>: 子卷类型，标明它是 <code class="docutils literal notranslate"><span class="pre">clone</span></code> 还是 <code class="docutils literal notranslate"><span class="pre">subvolume</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pool_namespace</span></code>: 子卷的 RADOS 命名空间</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">features</span></code>: 子卷支持的功能</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">state</span></code>: 这个子卷当前的状态</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">earmark</span></code>: 这个子卷的 earmark</p></li>
</ul>
<p>如果子卷已经删除，而它的快照保留下来了，
那么输出会只包含下列字段。</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">type</span></code>: 子卷类型，标明它是 <code class="docutils literal notranslate"><span class="pre">clone</span></code> 还是 <code class="docutils literal notranslate"><span class="pre">subvolume</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">features</span></code>: 子卷支持的功能</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">state</span></code>: 这个子卷当前的状态</p></li>
</ul>
<p>一个子卷的 <code class="docutils literal notranslate"><span class="pre">features</span></code> 基于此子卷的内部版本，
是下列中的一个子集：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">snapshot-clone</span></code>: 支持克隆，
用子卷的快照作为源</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">snapshot-autoprotect</span></code>: 如果快照是有用的克隆源，
此功能支持自动保护快照，以防删除。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">snapshot-retention</span></code>: 支持删除子卷内容，
却保留所有现存快照。</p></li>
</ul>
<p>一个子卷的 <code class="docutils literal notranslate"><span class="pre">state</span></code> 基于此子卷的当前状态，
且包含下列值之一：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">complete</span></code>: 子卷正常，可做任何操作</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">snapshot-retained</span></code>: 子卷删除了，但它的快照保留着</p></li>
</ul>
</section>
<section id="id11">
<h3>罗列子卷<a class="headerlink" href="#id11" title="Permalink to this heading"></a></h3>
<p>罗列子卷，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>ls<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>已经删除但保留了快照的那些子卷也会罗列出来。</p>
</div>
</section>
<section id="id12">
<h3>检查一个子卷是否存在<a class="headerlink" href="#id12" title="Permalink to this heading"></a></h3>
<p>检查一个指定子卷是否存在，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>exist<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">exist</span></code> 命令可能的结果：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">subvolume</span> <span class="pre">exists</span></code>: 如果指定的 <code class="docutils literal notranslate"><span class="pre">group_name</span></code> 里面有子卷</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">no</span> <span class="pre">subvolume</span> <span class="pre">exists</span></code>: 如果指定的 <code class="docutils literal notranslate"><span class="pre">group_name</span></code> 里面没有子卷</p></li>
</ul>
</section>
<section id="id13">
<h3>在一个子卷上设置自定义元数据<a class="headerlink" href="#id13" title="Permalink to this heading"></a></h3>
<p>在子卷上设置自定义的键值对元数据，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>metadata<span class="w"> </span><span class="nb">set</span><span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;key_name&gt;<span class="w"> </span>&lt;value&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果 key_name 已经存在，那么它的旧值会被新值替换。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">key_name</span></code> 和 <code class="docutils literal notranslate"><span class="pre">value</span></code> 应该是 ASCII 字符组成的字符串
（就是 Python 的 <code class="docutils literal notranslate"><span class="pre">string.printable</span></code> 指定的那些）。
<code class="docutils literal notranslate"><span class="pre">key_name</span></code> 不区分大小写，总是以小写保存。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>拍快照时不会保留子卷上的自定义元数据，
因此，克隆子卷快照时也不会保留。</p>
</div>
</section>
<section id="id14">
<h3>查看子卷的自定义元数据集合<a class="headerlink" href="#id14" title="Permalink to this heading"></a></h3>
<p>查看设置的自定义元数据，需指定元数据键名，
执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>metadata<span class="w"> </span>get<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;key_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id15">
<h3>罗列子卷的自定义元数据集合<a class="headerlink" href="#id15" title="Permalink to this heading"></a></h3>
<p>罗列子卷上设置的自定义元数据（键值对），执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>metadata<span class="w"> </span>ls<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id16">
<h3>删除子卷的一个自定义元数据集合<a class="headerlink" href="#id16" title="Permalink to this heading"></a></h3>
<p>删除子卷上设置的自定义元数据，需指定元数据键名，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>metadata<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;key_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--force<span class="o">]</span></span>
</pre></div></div><p>加 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 可以让此命令返回成功，否则它可能失败（如果删除的元数据键不存在）。</p>
</section>
<section id="id17">
<h3>查看子卷的 earmark<a class="headerlink" href="#id17" title="Permalink to this heading"></a></h3>
<p>查看子卷的 earmark ，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>earmark<span class="w"> </span>get<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id18">
<h3>设置子卷的 earmark<a class="headerlink" href="#id18" title="Permalink to this heading"></a></h3>
<p>设置子卷的 earmark ，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>earmark<span class="w"> </span><span class="nb">set</span><span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span><span class="w"> </span>&lt;earmark&gt;</span>
</pre></div></div></section>
<section id="id19">
<h3>删除子卷的 earmark<a class="headerlink" href="#id19" title="Permalink to this heading"></a></h3>
<p>删除子卷的 earmark ，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>earmark<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id20">
<h3>创建子卷的快照<a class="headerlink" href="#id20" title="Permalink to this heading"></a></h3>
<p>给子卷创建一个快照，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>create<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id21">
<h3>删除子卷的快照<a class="headerlink" href="#id21" title="Permalink to this heading"></a></h3>
<p>删除子卷的一个快照，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--force<span class="o">]</span></span>
</pre></div></div><p>加 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 选项可以让此命令成功，否则它可能失败（假如快照不存在）。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>对于一个保留了快照的子卷，如果它的最后一个快照删掉了，这个子卷也会删掉。</p>
</div>
</section>
<section id="id22">
<h3>罗列子卷的快照<a class="headerlink" href="#id22" title="Permalink to this heading"></a></h3>
<p>罗列子卷的快照，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>ls<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id23">
<h3>提取一个快照的信息<a class="headerlink" href="#id23" title="Permalink to this heading"></a></h3>
<p>提取一个快照的信息，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>info<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div><p>其输出是 JSON 格式的，包含下列字段。</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">created_at</span></code>: 快照的创建时间，按格式 <code class="docutils literal notranslate"><span class="pre">YYYY-MM-DD</span> <span class="pre">HH:MM:SS:ffffff</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">data_pool</span></code>: 快照所属的数据存储池</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">has_pending_clones</span></code>: 如果快照克隆正在进行中就是 <code class="docutils literal notranslate"><span class="pre">yes</span></code> ，否则就是 <code class="docutils literal notranslate"><span class="pre">no</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pending_clones</span></code>: 正在进行的或待定的克隆操作列表，
如果有目标组也会一并列出；否则此字段不显示。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">orphan_clones_count</span></code>: 如果有孤儿克隆，
这里就是孤儿克隆的数量，否则此字段不显示。</p></li>
</ul>
<p>有快照克隆正在进行或待定时的输出样本：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>info<span class="w"> </span>cephfs<span class="w"> </span>subvol<span class="w"> </span>snap</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;created_at&quot;</span><span class="p">:</span> <span class="s2">&quot;2022-06-14 13:54:58.618769&quot;</span><span class="p">,</span>
    <span class="s2">&quot;data_pool&quot;</span><span class="p">:</span> <span class="s2">&quot;cephfs.cephfs.data&quot;</span><span class="p">,</span>
    <span class="s2">&quot;has_pending_clones&quot;</span><span class="p">:</span> <span class="s2">&quot;yes&quot;</span><span class="p">,</span>
    <span class="s2">&quot;pending_clones&quot;</span><span class="p">:</span> <span class="p">[</span>
        <span class="p">{</span>
            <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;clone_1&quot;</span><span class="p">,</span>
            <span class="s2">&quot;target_group&quot;</span><span class="p">:</span> <span class="s2">&quot;target_subvol_group&quot;</span>
        <span class="p">},</span>
        <span class="p">{</span>
            <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;clone_2&quot;</span>
        <span class="p">},</span>
        <span class="p">{</span>
            <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;clone_3&quot;</span><span class="p">,</span>
            <span class="s2">&quot;target_group&quot;</span><span class="p">:</span> <span class="s2">&quot;target_subvol_group&quot;</span>
        <span class="p">}</span>
    <span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
<p>没有快照克隆正在进行或待定时的输出样本：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>info<span class="w"> </span>cephfs<span class="w"> </span>subvol<span class="w"> </span>snap</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;created_at&quot;</span><span class="p">:</span> <span class="s2">&quot;2022-06-14 13:54:58.618769&quot;</span><span class="p">,</span>
    <span class="s2">&quot;data_pool&quot;</span><span class="p">:</span> <span class="s2">&quot;cephfs.cephfs.data&quot;</span><span class="p">,</span>
    <span class="s2">&quot;has_pending_clones&quot;</span><span class="p">:</span> <span class="s2">&quot;no&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</section>
<section id="id24">
<h3>在一个快照上设置自定义键值对元数据<a class="headerlink" href="#id24" title="Permalink to this heading"></a></h3>
<p>在快照上设置自定义键值对元数据，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>metadata<span class="w"> </span><span class="nb">set</span><span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span>&lt;key_name&gt;<span class="w"> </span>&lt;value&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果 <code class="docutils literal notranslate"><span class="pre">key_name</span></code> 已经存在，那么旧值会被新值替换。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">key_name</span></code> 和它的值应该是 ASCII 字符组成的字符串
（就是 Python 的 <code class="docutils literal notranslate"><span class="pre">string.printable</span></code> 里指定的那些）。
<code class="docutils literal notranslate"><span class="pre">key_name</span></code> 不区分大小写，且总是存储小写的。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>拍子卷快照的时候，自定义元数据不会保留下来，
因此，克隆子卷快照时也不会保留。</p>
</div>
</section>
<section id="id25">
<h3>查看一个快照上设置的自定义元数据<a class="headerlink" href="#id25" title="Permalink to this heading"></a></h3>
<p>用元数据键、查看之前在快照上设置的自定义元数据，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>metadata<span class="w"> </span>get<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span>&lt;key_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id26">
<h3>罗列一个快照上设置的自定义元数据<a class="headerlink" href="#id26" title="Permalink to this heading"></a></h3>
<p>罗列快照上设置的自定义元数据（键值对），执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>metadata<span class="w"> </span>ls<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div></section>
<section id="id27">
<h3>删除快照的自定义元数据<a class="headerlink" href="#id27" title="Permalink to this heading"></a></h3>
<p>用元数据键、删除快照上设置的自定义元数据，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>metadata<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span>&lt;key_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span><span class="w"> </span><span class="o">[</span>--force<span class="o">]</span></span>
</pre></div></div><p>加 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 选项可以让此命令成功，否则它可能失败（如果指定的元数据键不存在）。</p>
</section>
</section>
<section id="id28">
<h2>克隆快照<a class="headerlink" href="#id28" title="Permalink to this heading"></a></h2>
<p>可以通过克隆子卷快照来创建子卷。
克隆是一种异步操作，可将数据从快照复制到子卷。
由于克隆是一种涉及大批量复制的操作，
因此对于非常大的数据集来说，速度会比较慢。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>如果有待定或正在进行的克隆操作，
删除快照（源子卷）会失败。</p>
</div>
<p>在 Nautilus 版里，克隆之前先保护快照是前提条件。
为此引入了可以保护和解除保护快照的命令。
这一前提条件已废弃，可能会在未来的版本中删除。</p>
<p>正在废弃的命令有：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>protect<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
<span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>unprotect<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;<span class="o">]</span></span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>使用上面的命令不会产生错误，但是它们没有实际用途。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>根据 <code class="docutils literal notranslate"><span class="pre">snapshot-autoprotect</span></code> （快照自动保护）功能是否可用，
用 <code class="docutils literal notranslate"><span class="pre">subvolume</span> <span class="pre">info</span></code> 命令提取子卷元数据，里面有支持的 <code class="docutils literal notranslate"><span class="pre">features</span></code> ，
可用来帮助决定是否需要保护/取消保护快照。</p>
</div>
<p>启动一个克隆操作，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>clone<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span>&lt;target_subvol_name&gt;</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">subvolume</span> <span class="pre">snapshot</span> <span class="pre">clone</span></code> 命令依赖于上面提过的配置选项 <code class="docutils literal notranslate"><span class="pre">snapshot_clone_no_wait</span></code></p>
</div>
<p>快照（源子卷）属于非默认组时，执行下列命令。注意，需要指定组名：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>clone<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span>&lt;target_subvol_name&gt;<span class="w"> </span>--group_name<span class="w"> </span>&lt;subvol_group_name&gt;</span>
</pre></div></div><p>克隆的子卷可以位于不同于源快照所属的组（默认情况下，
会在默认组中创建克隆的子卷）。克隆到指定组，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>clone<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span>&lt;target_subvol_name&gt;<span class="w"> </span>--target_group_name<span class="w"> </span>&lt;subvol_group_name&gt;</span>
</pre></div></div><p>创建克隆子卷时可以指定存储池布局，
指定方式类似于创建子卷时指定存储池布局。
创建具有指定存储池布局的克隆子卷，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>clone<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol_name&gt;<span class="w"> </span>&lt;snap_name&gt;<span class="w"> </span>&lt;target_subvol_name&gt;<span class="w"> </span>--pool_layout<span class="w"> </span>&lt;pool_layout&gt;</span>
</pre></div></div><p>检查克隆操作的状态，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>clone<span class="w"> </span>status<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;clone_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;group_name&gt;<span class="o">]</span></span>
</pre></div></div><p>克隆操作的状态可以是下列之一：</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">pending</span></code>     : 克隆操作尚未开始</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">in-progress</span></code> : 克隆操作正在进行</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">complete</span></code>    : 克隆操作已成功完成</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">failed</span></code>      : 克隆操作失败了</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">canceled</span></code>    : 用户取消了克隆操作</p></li>
</ol>
<p>克隆失败的原因有如下几个：</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">errno</span></code>     : 错误号</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">error_msg</span></code> : 失败的报错字符串</p></li>
</ol>
<p>这是一个 <code class="docutils literal notranslate"><span class="pre">in-progress</span></code> （正在进行的）克隆实例:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>clone<span class="w"> </span>cephfs<span class="w"> </span>subvol1<span class="w"> </span>snap1<span class="w"> </span>clone1</span>
<span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>clone<span class="w"> </span>status<span class="w"> </span>cephfs<span class="w"> </span>clone1</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="p">{</span>
    <span class="s2">&quot;state&quot;</span><span class="p">:</span> <span class="s2">&quot;in-progress&quot;</span><span class="p">,</span>
    <span class="s2">&quot;source&quot;</span><span class="p">:</span> <span class="p">{</span>
      <span class="s2">&quot;volume&quot;</span><span class="p">:</span> <span class="s2">&quot;cephfs&quot;</span><span class="p">,</span>
      <span class="s2">&quot;subvolume&quot;</span><span class="p">:</span> <span class="s2">&quot;subvol1&quot;</span><span class="p">,</span>
      <span class="s2">&quot;snapshot&quot;</span><span class="p">:</span> <span class="s2">&quot;snap1&quot;</span>
    <span class="p">},</span>
    <span class="s2">&quot;progress_report&quot;</span><span class="p">:</span> <span class="p">{</span>
      <span class="s2">&quot;percentage cloned&quot;</span><span class="p">:</span> <span class="s2">&quot;12.24%&quot;</span><span class="p">,</span>
      <span class="s2">&quot;amount cloned&quot;</span><span class="p">:</span> <span class="s2">&quot;376M/3.0G&quot;</span><span class="p">,</span>
      <span class="s2">&quot;files cloned&quot;</span><span class="p">:</span> <span class="s2">&quot;4/6&quot;</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>当克隆正在进行时，输出中还会打印一份进度报告。
这里只报告指定克隆的进度。
对于所有正在进行的克隆的总体进度，
<code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">status</span></code> 命令的输出结果底部会打印一个进度条：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">progress</span><span class="p">:</span>
  <span class="mi">3</span> <span class="n">ongoing</span> <span class="n">clones</span> <span class="o">-</span> <span class="n">average</span> <span class="n">progress</span> <span class="ow">is</span> <span class="mf">47.569</span><span class="o">%</span> <span class="p">(</span><span class="mi">10</span><span class="n">s</span><span class="p">)</span>
    <span class="p">[</span><span class="o">=============...............</span><span class="p">]</span> <span class="p">(</span><span class="n">remaining</span><span class="p">:</span> <span class="mi">11</span><span class="n">s</span><span class="p">)</span>
</pre></div>
</div>
<p>如果克隆的任务数多于克隆线程数，则会打印两个进度条，
一个是正在进行的克隆（与上述相同），
另一个是所有（正在进行的+待处理的）克隆：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">progress</span><span class="p">:</span>
  <span class="mi">4</span> <span class="n">ongoing</span> <span class="n">clones</span> <span class="o">-</span> <span class="n">average</span> <span class="n">progress</span> <span class="ow">is</span> <span class="mf">27.669</span><span class="o">%</span> <span class="p">(</span><span class="mi">15</span><span class="n">s</span><span class="p">)</span>
    <span class="p">[</span><span class="o">=======.....................</span><span class="p">]</span> <span class="p">(</span><span class="n">remaining</span><span class="p">:</span> <span class="mi">41</span><span class="n">s</span><span class="p">)</span>
  <span class="n">Total</span> <span class="mi">5</span> <span class="n">clones</span> <span class="o">-</span> <span class="n">average</span> <span class="n">progress</span> <span class="ow">is</span> <span class="mf">41.667</span><span class="o">%</span> <span class="p">(</span><span class="mi">3</span><span class="n">s</span><span class="p">)</span>
    <span class="p">[</span><span class="o">===========.................</span><span class="p">]</span> <span class="p">(</span><span class="n">remaining</span><span class="p">:</span> <span class="mi">4</span><span class="n">s</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>只有在克隆状态为 <code class="docutils literal notranslate"><span class="pre">failed</span></code> 或 <code class="docutils literal notranslate"><span class="pre">canceled</span></code> 时，才会显示 <code class="docutils literal notranslate"><span class="pre">failure</span></code> 段。</p>
</div>
<p>这是个 <code class="docutils literal notranslate"><span class="pre">failed</span></code> 克隆的实例：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>clone<span class="w"> </span>cephfs<span class="w"> </span>subvol1<span class="w"> </span>snap1<span class="w"> </span>clone1</span>
<span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>clone<span class="w"> </span>status<span class="w"> </span>cephfs<span class="w"> </span>clone1</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;state&quot;</span><span class="p">:</span> <span class="s2">&quot;failed&quot;</span><span class="p">,</span>
        <span class="s2">&quot;source&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;volume&quot;</span><span class="p">:</span> <span class="s2">&quot;cephfs&quot;</span><span class="p">,</span>
            <span class="s2">&quot;subvolume&quot;</span><span class="p">:</span> <span class="s2">&quot;subvol1&quot;</span><span class="p">,</span>
            <span class="s2">&quot;snapshot&quot;</span><span class="p">:</span> <span class="s2">&quot;snap1&quot;</span>
            <span class="s2">&quot;size&quot;</span><span class="p">:</span> <span class="s2">&quot;104857600&quot;</span>
        <span class="p">},</span>
        <span class="s2">&quot;failure&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;errno&quot;</span><span class="p">:</span> <span class="s2">&quot;122&quot;</span><span class="p">,</span>
            <span class="s2">&quot;errstr&quot;</span><span class="p">:</span> <span class="s2">&quot;Disk quota exceeded&quot;</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>由于 <code class="docutils literal notranslate"><span class="pre">subvol1</span></code> 位于默认组里，所以，
<code class="docutils literal notranslate"><span class="pre">source</span></code> 对象的 <code class="docutils literal notranslate"><span class="pre">clone</span> <span class="pre">status</span></code> 没有包括组名。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>只有克隆操作成功完成后，
才能访问到克隆的子卷。</p>
</div>
<p>克隆操作成功完成后，
<code class="docutils literal notranslate"><span class="pre">clone</span> <span class="pre">status</span></code> 结果如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>clone<span class="w"> </span>status<span class="w"> </span>cephfs<span class="w"> </span>clone1</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;state&quot;</span><span class="p">:</span> <span class="s2">&quot;complete&quot;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>如果克隆操作不成功， <code class="docutils literal notranslate"><span class="pre">state</span></code> 的值将是 <code class="docutils literal notranslate"><span class="pre">failed</span></code> 。</p>
<p>要重试失败的克隆操作，必须先删除未完成的克隆，
并再次发起克隆操作。</p>
<p>要删除一个部分完成的克隆，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;clone_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;group_name&gt;<span class="o">]</span><span class="w"> </span>--force</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>克隆操作只同步目录、常规文件和符号链接。
inode 时间戳（访问和修改时间）的同步粒度能达到秒级。</p>
</div>
<p>处于 <code class="docutils literal notranslate"><span class="pre">in-progress</span></code> 或者 <code class="docutils literal notranslate"><span class="pre">pending</span></code> 状态的克隆操作可以取消。
取消克隆操作用 <code class="docutils literal notranslate"><span class="pre">clone</span> <span class="pre">cancel</span></code> 命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>clone<span class="w"> </span>cancel<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;clone_name&gt;<span class="w"> </span><span class="o">[</span>--group_name<span class="w"> </span>&lt;group_name&gt;<span class="o">]</span></span>
</pre></div></div><p>成功取消后，克隆的子卷状态会变成 <code class="docutils literal notranslate"><span class="pre">canceled</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>clone<span class="w"> </span>cephfs<span class="w"> </span>subvol1<span class="w"> </span>snap1<span class="w"> </span>clone1</span>
<span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>clone<span class="w"> </span>cancel<span class="w"> </span>cephfs<span class="w"> </span>clone1</span>
<span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>clone<span class="w"> </span>status<span class="w"> </span>cephfs<span class="w"> </span>clone1</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;state&quot;</span><span class="p">:</span> <span class="s2">&quot;canceled&quot;</span><span class="p">,</span>
        <span class="s2">&quot;source&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;volume&quot;</span><span class="p">:</span> <span class="s2">&quot;cephfs&quot;</span><span class="p">,</span>
            <span class="s2">&quot;subvolume&quot;</span><span class="p">:</span> <span class="s2">&quot;subvol1&quot;</span><span class="p">,</span>
            <span class="s2">&quot;snapshot&quot;</span><span class="p">:</span> <span class="s2">&quot;snap1&quot;</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>删除已取消的克隆品用 <code class="docutils literal notranslate"><span class="pre">fs</span> <span class="pre">subvolume</span> <span class="pre">rm</span></code> 命令，
要加 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 选项。</p>
</div>
<section id="id29">
<h3>可配置选项<a class="headerlink" href="#id29" title="Permalink to this heading"></a></h3>
<p>配置克隆操作的最大并行数量，默认为 4 ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>config<span class="w"> </span><span class="nb">set</span><span class="w"> </span>mgr<span class="w"> </span>mgr/volumes/max_concurrent_clones<span class="w"> </span>&lt;value&gt;</span>
</pre></div></div><p>暂停异步清除回收站子卷的线程。此选项在集群恢复期间有用：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>config<span class="w"> </span><span class="nb">set</span><span class="w"> </span>mgr/volumes/pause_purging<span class="w"> </span><span class="nb">true</span></span>
</pre></div></div><p>恢复用于清除的线程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>config<span class="w"> </span><span class="nb">set</span><span class="w"> </span>mgr/volumes/pause_purging<span class="w"> </span><span class="nb">false</span></span>
</pre></div></div><p>暂停异步克隆子卷快照的线程。此选项在集群恢复期间有用：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>config<span class="w"> </span><span class="nb">set</span><span class="w"> </span>mgr/volumes/pause_cloning<span class="w"> </span><span class="nb">true</span></span>
</pre></div></div><p>恢复用于克隆的线程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>config<span class="w"> </span><span class="nb">set</span><span class="w"> </span>mgr/volumes/pause_cloning<span class="w"> </span><span class="nb">false</span></span>
</pre></div></div><p>配置 <code class="docutils literal notranslate"><span class="pre">snapshot_clone_no_wait</span></code> 选项：</p>
<p><code class="docutils literal notranslate"><span class="pre">snapshot_clone_no_wait</span></code> 配置选项用于在克隆线程
（可用上述选项进行配置，例如 <code class="docutils literal notranslate"><span class="pre">max_concurrent_clones</span></code> ）
不可用时拒绝克隆创建请求。此选项默认是启用的。
意思是该值被设置成了 <code class="docutils literal notranslate"><span class="pre">True</span></code> ，但可以用下列命令进行配置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>config<span class="w"> </span><span class="nb">set</span><span class="w"> </span>mgr<span class="w"> </span>mgr/volumes/snapshot_clone_no_wait<span class="w"> </span>&lt;bool&gt;</span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">snapshot_clone_no_wait</span></code> 当前的值可以用下列命令提取。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>config<span class="w"> </span>get<span class="w"> </span>mgr<span class="w"> </span>mgr/volumes/snapshot_clone_no_wait</span>
</pre></div></div></section>
</section>
<section id="subvol-pinning">
<span id="id30"></span><h2>锁定子卷和子卷组<a class="headerlink" href="#subvol-pinning" title="Permalink to this heading"></a></h2>
<p>子卷和子卷组可根据策略自动锁定（ pinned ）到 rank 。
这样可以按可预测且稳定的方式在 MDS rank 之间分配负载。
详细了解锁定机制，请看 <a class="reference internal" href="../multimds/#cephfs-pinning"><span class="std std-ref">手动将目录树插入特定的 rank</span></a> 和
<a class="reference internal" href="../multimds/#cephfs-ephemeral-pinning"><span class="std std-ref">设置子树分区策略</span></a> 。</p>
<p>配置子卷组的锁定，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>pin<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span>&lt;pin_type&gt;<span class="w"> </span>&lt;pin_setting&gt;</span>
</pre></div></div><p>配置子卷的锁定，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>pin<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span>&lt;pin_type&gt;<span class="w"> </span>&lt;pin_setting&gt;</span>
</pre></div></div><p>在大多数情况下，都需要设置子卷组锁定。 <code class="docutils literal notranslate"><span class="pre">pin_type</span></code> 可以是 <code class="docutils literal notranslate"><span class="pre">export</span></code> （导出）、
<code class="docutils literal notranslate"><span class="pre">distributed</span></code> （分布式）或 <code class="docutils literal notranslate"><span class="pre">random</span></code> （随机）。
<code class="docutils literal notranslate"><span class="pre">pin_setting</span></code> 对应扩展属性的 “value” ，这在上文提到的锁定文档里有。</p>
<p>下面是个实例，在子卷组上设置分布式锁定策略：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>pin<span class="w"> </span>cephfilesystem-a<span class="w"> </span>csi<span class="w"> </span>distributed<span class="w"> </span><span class="m">1</span></span>
</pre></div></div><p>此命令将在 csi 子卷组上启用分布式子树分区策略。
这会让组内的每个子卷自动锁定到文件系统内的一个可用 rank 。</p>
</section>
<section id="id31">
<h2>规范化和大小写敏感<a class="headerlink" href="#id31" title="Permalink to this heading"></a></h2>
<p>subvolumegroup 和 subvolume 接口有一个 porcelain layer API （统一抽象层），
用于操作 <code class="docutils literal notranslate"><span class="pre">ceph.dir.charmap</span></code> 配置（另请参阅 <a class="reference internal" href="../charmap/#charmap"><span class="std std-ref">CephFS 目录条目名字规范化和大小写折叠</span></a> ）。</p>
<section id="charmap">
<h3>charmap 的配置<a class="headerlink" href="#charmap" title="Permalink to this heading"></a></h3>
<p>要给一个 subvolumegroup 配置 charmap ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>charmap<span class="w"> </span><span class="nb">set</span><span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span>&lt;setting&gt;<span class="w"> </span>&lt;value&gt;</span>
</pre></div></div><p>或者给一个 subvolume 配置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>charmap<span class="w"> </span><span class="nb">set</span><span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol&gt;<span class="w"> </span>&lt;--group_name<span class="o">=</span>name&gt;<span class="w"> </span>&lt;setting&gt;<span class="w"> </span>&lt;value&gt;</span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>charmap<span class="w"> </span><span class="nb">set</span><span class="w"> </span>vol<span class="w"> </span>csi<span class="w"> </span>normalization<span class="w"> </span>nfd</span>
</pre></div></div><p>命令输出：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="s2">&quot;casesensitive&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span><span class="s2">&quot;normalization&quot;</span><span class="p">:</span><span class="s2">&quot;nfd&quot;</span><span class="p">,</span><span class="s2">&quot;encoding&quot;</span><span class="p">:</span><span class="s2">&quot;utf8&quot;</span><span class="p">}</span>
</pre></div>
</div>
</section>
<section id="id32">
<h3>读取 charmap<a class="headerlink" href="#id32" title="Permalink to this heading"></a></h3>
<p>要读取一个 subvolumegroup 的配置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>charmap<span class="w"> </span>get<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;<span class="w"> </span>&lt;setting&gt;</span>
</pre></div></div><p>或者一个 subvolume 的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>charmap<span class="w"> </span>get<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol&gt;<span class="w"> </span>&lt;--group_name<span class="o">=</span>name&gt;<span class="w"> </span>&lt;setting&gt;</span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>charmap<span class="w"> </span>get<span class="w"> </span>vol<span class="w"> </span>subvol<span class="w"> </span>--group_name<span class="o">=</span>csi<span class="w"> </span>casesensitive</span>
</pre></div></div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span>
</pre></div>
</div>
<p>要读取完整的 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> ，读取 subvolumegroup 的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>charmap<span class="w"> </span>get<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name&gt;</span>
</pre></div></div><p>或者读取 subvolume 的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>charmap<span class="w"> </span>get<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol&gt;<span class="w"> </span>&lt;--group_name<span class="o">=</span>name&gt;</span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>charmap<span class="w"> </span>get<span class="w"> </span>vol<span class="w"> </span>csi</span>
</pre></div></div><p>命令输出：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="s2">&quot;casesensitive&quot;</span><span class="p">:</span><span class="n">false</span><span class="p">,</span><span class="s2">&quot;normalization&quot;</span><span class="p">:</span><span class="s2">&quot;nfd&quot;</span><span class="p">,</span><span class="s2">&quot;encoding&quot;</span><span class="p">:</span><span class="s2">&quot;utf8&quot;</span><span class="p">}</span>
</pre></div>
</div>
</section>
<section id="id33">
<h3>删除 charmap<a class="headerlink" href="#id33" title="Permalink to this heading"></a></h3>
<p>要删除一个 subvolumegroup 的配置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>charmap<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;group_name</span>
</pre></div></div><p>或者一个 subvolume 的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>charmap<span class="w"> </span>rm<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>&lt;subvol&gt;<span class="w"> </span>&lt;--group_name<span class="o">=</span>name&gt;</span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>subvolumegroup<span class="w"> </span>charmap<span class="w"> </span>rm<span class="w"> </span>vol<span class="w"> </span>csi</span>
</pre></div></div><p>输出：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>只有当 subvolumegroup 或 subvolume 为空的时候才能删除 charmap 。</p>
</div>
</section>
</section>
<section id="subvolume-quiesce">
<h2>子卷静默（ subvolume quiesce ）<a class="headerlink" href="#subvolume-quiesce" title="Permalink to this heading"></a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>此段落信息只适用于 Squid 以及更高版本。</p>
</div>
<p>CephFS 快照不能保证强一致性，因为在多个客户端执行写操作的情况下，
一致性备份和灾难恢复是分布式应用程序不得不面临的严峻挑战。
即使应用程序能够使用文件系统刷回功能来同步其分布式组件中的检查点的情况下，
也不能保证所有确认的写入都会进入指定快照。</p>
<p>为此，开发出了子卷静默（ quiesce ）功能，目的是为多客户端应用程序提供企业级一致性保证，这些应用程序使用着一个或多个子卷。有了这个功能，
可以暂停指定卷（文件系统）的一组子卷的 IO 。通过在所有客户端强制执行这种暂停，
可以保证应用程序在暂停前到达的所有持久（已写入的）检查点、
都可以从暂停期间拍下的快照中恢复。</p>
<p><cite>volumes</cite> 插件提供了一个 CLI ，用于启动和等待一组子卷的暂停。
这种暂停称为 <cite>quiesce</cite> （静默），也用作命令名称：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt2:before {
  content: "$ ";
}
</style><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>--set-id<span class="w"> </span>myset1<span class="w"> </span>&lt;<span class="o">[</span>group_name/<span class="o">]</span>sub_name...&gt;<span class="w"> </span>--await
<span class="c1"># 在 IO 暂停生效后执行动作，比如拍快照</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>&lt;vol_name&gt;<span class="w"> </span>--set-id<span class="w"> </span>myset1<span class="w"> </span>--release<span class="w"> </span>--await
<span class="c1"># 如果成功，就认为此集合的所有成员仍被暂停着，然后释放它们</span></span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">fs</span> <span class="pre">quiesce</span></code> 功能基于更底层的 <code class="docutils literal notranslate"><span class="pre">quiesce</span> <span class="pre">db</span></code> 服务，它是由 MDS 守护进程提供的，
操作粒度可达到文件系统路径。 <cite>volumes</cite> 插件只是把子卷名映射到指定文件系统内的相应路径，然后向 MDS 发出相应的 <code class="docutils literal notranslate"><span class="pre">quiesce</span> <span class="pre">db</span></code> 命令。
有关底层服务的更多信息，参阅开发者文档。</p>
<section id="id34">
<h3>可用操作<a class="headerlink" href="#id34" title="Permalink to this heading"></a></h3>
<p>quiesce （静默）操作可以作用于一个或多个子卷（就是文件系统中的路径）组成的集合，
此集合称为 <cite>quiesce set</cite> 。每个 <cite>quiesce set</cite> 都用一个唯一的 <cite>set id</cite> 标识。
可以通过以下方式操作 <cite>quiesce set</cite> ：</p>
<ul class="simple">
<li><p><strong>include</strong> （包含）一或多个子卷 - quiesce set 成员</p></li>
<li><p><strong>exclude</strong> （排除）一或多个成员</p></li>
<li><p><strong>cancel</strong> （取消）此集合，异步地中止当前所有成员的暂停</p></li>
<li><p><strong>release</strong> （释放）此集合，请求结束所有成员的暂停，并需要得到所有客户端的确认。</p></li>
<li><p><strong>query</strong> （查询）集合当前的状态，用 id 指定单个集合、或所有有效集合、或所有已知集合</p></li>
<li><p><strong>cancel all</strong> （取消所有）有效集合，这是需要立即恢复 IO</p></li>
</ul>
<p>上述操作都是非阻塞操作：它们只是尝试想做的修改，
并返回目标集合的最新版本，而不管操作是否会成功。
集合的状态可能会因修改而改变，而响应返回的版本能保证与此操作、
还有同一控制循环批次中其他可能的成功操作的状态一致。</p>
<p>有些集合的状态是 <cite>awaitable</cite> 。我们将在下文讨论这些状态，但现在有必要提及的是，
上述所有命令都可以用 <strong>await</strong> 修饰符进行修改，这会让它们在应用想要的修改后一直阻塞在集合上，前提是此集合状态为 <cite>awaitable</cite> 。这样的命令会一直阻塞，
直到集合到达等待的那个状态、或被其他命令修改、或转换成另一个状态。
返回码会明确说明退出的条件，响应内容将始终包含已知的最新集合状态。</p>
<img alt="../../_images/quiesce-set-states.svg" src="../../_images/quiesce-set-states.svg" /><p>图中的 <cite>Awaitable</cite> 状态用 <code class="docutils literal notranslate"><span class="pre">(a)</span></code> 或 <code class="docutils literal notranslate"><span class="pre">(A)</span></code> 标记了。当此集合处于 <code class="docutils literal notranslate"><span class="pre">(a)</span></code> 状态时，
阻塞着的操作将处于等待状态；如果集合到达 <code class="docutils literal notranslate"><span class="pre">(A)</span></code> 状态，操作就成功地完成。
如果此集合已经处于 <code class="docutils literal notranslate"><span class="pre">(A)</span></code> 状态，那么操作会立即成功完成。</p>
<p>大多数操作都需要带集合 ID （ set-id ），例外的有：</p>
<ul class="simple">
<li><p>创建新集合，却没有指定集合 id</p></li>
<li><p>查询有效的、或所有已知集合，还有</p></li>
<li><p>取消所有</p></li>
</ul>
<p>通过 <cite>include</cite> 或 <cite>reset</cite> 命令拉进成员，即可创建一个新集合。可以指定集合 id ，
而且如果它是新 id ，那么这个集合带着指定成员一创建就处于 <cite>QUIESCING</cite> 状态。
如果在包含或重置成员时没有指定集合 id ，就会创建一个具有唯一集合 id 的新集合。
在输出里就能找到它的集合 id ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>sub1<span class="w"> </span>--set-id<span class="o">=</span>unique-id
<span class="o">{</span>
<span class="w">    </span><span class="s2">&quot;epoch&quot;</span>:<span class="w"> </span><span class="m">3</span>,
<span class="w">    </span><span class="s2">&quot;set_version&quot;</span>:<span class="w"> </span><span class="m">1</span>,
<span class="w">    </span><span class="s2">&quot;sets&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">        </span><span class="s2">&quot;unique-id&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">            </span><span class="s2">&quot;version&quot;</span>:<span class="w"> </span><span class="m">1</span>,
<span class="w">            </span><span class="s2">&quot;age_ref&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;TIMEDOUT&quot;</span>,
<span class="w">                </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">0</span>.0
<span class="w">            </span><span class="o">}</span>,
<span class="w">            </span><span class="s2">&quot;timeout&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;expiration&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;members&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;file:/volumes/_nogroup/sub1/b1fcce76-3418-42dd-aa76-f9076d047dd3&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                    </span><span class="s2">&quot;excluded&quot;</span>:<span class="w"> </span>false,
<span class="w">                    </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                        </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                        </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">0</span>.0
<span class="w">                    </span><span class="o">}</span>
<span class="w">                </span><span class="o">}</span>
<span class="w">            </span><span class="o">}</span>
<span class="w">        </span><span class="o">}</span>
<span class="w">    </span><span class="o">}</span>
<span class="o">}</span></span>
</pre></div></div><p>输出中包含了我们刚刚成功创建的集合，但它已经超时了（ <cite>TIMEDOUT</cite> ）。
这是符合预期的，因为我们没有给这个 quiesce 指定超时时间，
而且我们可以从输出中看到，它的默认初始化值为 0 ，同时还有过期时间。</p>
</section>
<section id="id35">
<h3>超时选项<a class="headerlink" href="#id35" title="Permalink to this heading"></a></h3>
<p>两个超时参数，即 <cite>timeout</cite> 和 <cite>expiration</cite> ，是防止应用程序意外引起 DOS 状况
（ DOS condition, Denial-of-Service 拒绝服务？）的主要防护措施。
任何操作有效集合的命令都可以加 <code class="docutils literal notranslate"><span class="pre">--timeout</span></code> 或 <code class="docutils literal notranslate"><span class="pre">--expiration</span></code> 参数，
用以更新这个集合的值。如果存在，那么此命令请求执行的操作之前，会先应用更新的值。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="o">=</span>unique-id<span class="w"> </span>--timeout<span class="o">=</span><span class="m">10</span><span class="w"> </span>&gt;<span class="w"> </span>/dev/null
Error<span class="w"> </span>EPERM:</span>
</pre></div></div><p>对我们的 <code class="docutils literal notranslate"><span class="pre">unique-id</span></code> 集合来说已经太晚了，因为它已处于终结状态。
处于终结状态（即非活动、无效状态）时，就不允许再更改集合了。我们新建一个集合：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>sub1<span class="w"> </span>--timeout<span class="w"> </span><span class="m">60</span>
<span class="o">{</span>
<span class="w">    </span><span class="s2">&quot;epoch&quot;</span>:<span class="w"> </span><span class="m">3</span>,
<span class="w">    </span><span class="s2">&quot;set_version&quot;</span>:<span class="w"> </span><span class="m">2</span>,
<span class="w">    </span><span class="s2">&quot;sets&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">        </span><span class="s2">&quot;8988b419&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">            </span><span class="s2">&quot;version&quot;</span>:<span class="w"> </span><span class="m">2</span>,
<span class="w">            </span><span class="s2">&quot;age_ref&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">0</span>.0
<span class="w">            </span><span class="o">}</span>,
<span class="w">            </span><span class="s2">&quot;timeout&quot;</span>:<span class="w"> </span><span class="m">60</span>.0,
<span class="w">            </span><span class="s2">&quot;expiration&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;members&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;file:/volumes/_nogroup/sub1/b1fcce76-3418-42dd-aa76-f9076d047dd3&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                    </span><span class="s2">&quot;excluded&quot;</span>:<span class="w"> </span>false,
<span class="w">                    </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                        </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                        </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">0</span>.0
<span class="w">                    </span><span class="o">}</span>
<span class="w">                </span><span class="o">}</span>
<span class="w">            </span><span class="o">}</span>
<span class="w">        </span><span class="o">}</span>
<span class="w">    </span><span class="o">}</span>
<span class="o">}</span></span>
</pre></div></div><p>这次，我们没有指定集合 id ，因此系统创建了一个新 id 。
我们在输出中看到了它的 id ，是 <code class="docutils literal notranslate"><span class="pre">8988b419</span></code> 。命令执行成功了，
我们可以看到这次的集合处于 <cite>QUIESCING</cite> 状态。此时，我们可以向此集合添加更多成员：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="w"> </span>8988b419<span class="w"> </span>--include<span class="w"> </span>sub2<span class="w"> </span>sub3
<span class="o">{</span>
<span class="w">    </span><span class="s2">&quot;epoch&quot;</span>:<span class="w"> </span><span class="m">3</span>,
<span class="w">    </span><span class="s2">&quot;set_version&quot;</span>:<span class="w"> </span><span class="m">3</span>,
<span class="w">    </span><span class="s2">&quot;sets&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">        </span><span class="s2">&quot;8988b419&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">            </span><span class="s2">&quot;version&quot;</span>:<span class="w"> </span><span class="m">3</span>,
<span class="w">            </span><span class="s2">&quot;age_ref&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">30</span>.7
<span class="w">            </span><span class="o">}</span>,
<span class="w">            </span><span class="s2">&quot;timeout&quot;</span>:<span class="w"> </span><span class="m">60</span>.0,
<span class="w">            </span><span class="s2">&quot;expiration&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;members&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;file:/volumes/_nogroup/sub1/b1fcce76-3418-42dd-aa76-f9076d047dd3&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                    </span><span class="s2">&quot;excluded&quot;</span>:<span class="w"> </span>false,
<span class="w">                    </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                        </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                        </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">30</span>.7
<span class="w">                    </span><span class="o">}</span>
<span class="w">                </span><span class="o">}</span>,
<span class="w">                </span><span class="s2">&quot;file:/volumes/_nogroup/sub2/bc8f770e-7a43-48f3-aa26-d6d76ef98d3e&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                    </span><span class="s2">&quot;excluded&quot;</span>:<span class="w"> </span>false,
<span class="w">                    </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                        </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                        </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">0</span>.0
<span class="w">                    </span><span class="o">}</span>
<span class="w">                </span><span class="o">}</span>,
<span class="w">                </span><span class="s2">&quot;file:/volumes/_nogroup/sub3/24c4b57b-e249-4b89-b4fa-7a810edcd35b&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                    </span><span class="s2">&quot;excluded&quot;</span>:<span class="w"> </span>false,
<span class="w">                    </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                        </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                        </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">0</span>.0
<span class="w">                    </span><span class="o">}</span>
<span class="w">                </span><span class="o">}</span>
<span class="w">            </span><span class="o">}</span>
<span class="w">        </span><span class="o">}</span>
<span class="w">    </span><span class="o">}</span>
<span class="o">}</span></span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">--include</span></code> 位是可选的，因为，如果在提供成员时没有指定操作，
那就认为是 “include” 操作。</p>
<p>正如我们所看到的，超时参数指定了我们准备给系统多少时间等这个集合到达
<cite>QUIESCED</cite> 状态。不过，由于新成员可以随时添加进有效集合中，
因此从集合创建时间开始算超时时间并不公平。因此，超时是按成员来跟踪的：
每个成员都有 <cite>timeout</cite> 秒数的时间进入静默状态，如果任何一个成员的静默时间超过了这一时间，整个集合就会被标记为 <cite>TIMEDOUT</cite> ，并释放暂停。</p>
<p>一旦集合进入 <cite>QUIESCED</cite> 状态，它就会启动过期计时器（ expiration timer ）。
该计时器是按整个集合跟踪的，而不是按每个成员。 <cite>expiration</cite> 秒数一过，
集合就会变成 <cite>EXPIRED</cite> （已过期）状态，除非主动操作去释放或取消。</p>
<p>可以向 <cite>QUIESCED</cite> （已静默）的集合添加新成员。在这种情况下，
它会回到 <cite>QUIESCING</cite> （正进入静默）状态，新成员会有自己的静默超时。
如果新成员成功，那么该集合将再次 <cite>QUIESCED</cite> ，过期计时器将重启。</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<ul class="simple">
<li><p>集合处于 <cite>QUIESCING</cite> 状态时， <cite>expiration timer</cite> （过期计时器）不会启动；
当这个<strong>集合</strong>变成 <cite>QUIESCED</cite> 状态后，它的值会重置成 <cite>expiration</cite> 属性的值。</p></li>
<li><p><cite>timeout</cite> 不会影响已经处于 <cite>QUIESCED</cite> 状态的<strong>成员</strong>。</p></li>
</ul>
</div>
</section>
<section id="await">
<h3>await （等待）<a class="headerlink" href="#await" title="Permalink to this heading"></a></h3>
<p>注意，上述命令都是非阻塞的。如果我们想等待静默集合达到 <cite>QUIESCED</cite> 状态，
就应该在某个点等待它。 <code class="docutils literal notranslate"><span class="pre">--await</span></code> 可以和其他参数一并送出，让系统知道我们的意图。</p>
<p>await 有两种类型： <cite>quiesce await</cite> 和 <cite>release await</cite> 。前者是默认的，
后者只有在参数里有 <code class="docutils literal notranslate"><span class="pre">--release</span></code> 时才能做到。为了避免混淆，当集合不是
<cite>QUIESCING</cite> 时，不允许发出 <cite>quiesce await</cite> 。同样地，无论是否加 await ，试图
<code class="docutils literal notranslate"><span class="pre">--release</span></code> （释放）一个未进入 <cite>QUIESCED</cite> 状态的集合也会得到 <code class="docutils literal notranslate"><span class="pre">EPERM</span></code> 错误。
不过， <cite>release await</cite> 一个已释放的集合、或 <cite>quiesce await</cite> 一个已静默的集合，
都不是错误 -- 这些都是成功的未操作（ no-op ）。</p>
<p>由于集合在等着应用程序（命令加了 <code class="docutils literal notranslate"><span class="pre">--await</span></code> 参数）， await 操作可能会用它自己的错误掩盖成功的结果。一个很好的例子就是尝试 cancel-await （等着取消）一个集合：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="w"> </span>set1<span class="w"> </span>--cancel<span class="w"> </span>--await
<span class="o">{</span>
<span class="w">    </span>//<span class="w"> </span>...
<span class="w">    </span><span class="s2">&quot;sets&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">        </span><span class="s2">&quot;set1&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">            </span>//<span class="w"> </span>...
<span class="w">            </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;CANCELED&quot;</span>,
<span class="w">                </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">0</span>
<span class="w">            </span><span class="o">}</span>,
<span class="w">            </span>//<span class="w"> </span>...
<span class="w">        </span><span class="o">}</span>
<span class="w">    </span><span class="o">}</span>
<span class="o">}</span>
Error<span class="w"> </span>EPERM:</span>
</pre></div></div><p>虽然对处于有效状态的集合， <code class="docutils literal notranslate"><span class="pre">--cancel</span></code> 会同步地成功，但不允许等待已经取消的集合，
因此这个调用会导致 <cite>EPERM`</cite> 。这是有意与返回 <code class="docutils literal notranslate"><span class="pre">EINVAL</span></code> 错误
（表示用户方面出错）不同的，目的是简化请求 <code class="docutils literal notranslate"><span class="pre">--await</span></code> 时的系统行为。
这样，对于用户来说，这也是一个更简单的模型。</p>
<p>在等待时，用户可以指定这个等待请求的最长期限，与前文讨论过的两个超时一致。
如果在指定的期限内未达到期望等到的状态，则会返回 <code class="docutils literal notranslate"><span class="pre">EINPROGRESS</span></code> 。为此，
应该使用参数 <code class="docutils literal notranslate"><span class="pre">--await-for=&lt;seconds&gt;</span></code> 。我们可以认为 <code class="docutils literal notranslate"><span class="pre">--await</span></code> 相当于
<code class="docutils literal notranslate"><span class="pre">--await-for=Infinity</span></code> （无限等待）。虽然同时指定这两个参数不合理，
但不会被当作错误。如果同时存在 <code class="docutils literal notranslate"><span class="pre">--await</span></code> 和 <code class="docutils literal notranslate"><span class="pre">--await-for</span></code> 参数，
那么前者将被忽略，而采纳 <code class="docutils literal notranslate"><span class="pre">--await-for</span></code> 的时间限制。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2"><span class="nb">time</span><span class="w"> </span>ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>sub1<span class="w"> </span>--timeout<span class="o">=</span><span class="m">10</span><span class="w"> </span>--await-for<span class="o">=</span><span class="m">2</span>
<span class="o">{</span>
<span class="w">    </span><span class="s2">&quot;epoch&quot;</span>:<span class="w"> </span><span class="m">6</span>,
<span class="w">    </span><span class="s2">&quot;set_version&quot;</span>:<span class="w"> </span><span class="m">3</span>,
<span class="w">    </span><span class="s2">&quot;sets&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">        </span><span class="s2">&quot;c3c1d8de&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">            </span><span class="s2">&quot;version&quot;</span>:<span class="w"> </span><span class="m">3</span>,
<span class="w">            </span><span class="s2">&quot;age_ref&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">2</span>.0
<span class="w">            </span><span class="o">}</span>,
<span class="w">            </span><span class="s2">&quot;timeout&quot;</span>:<span class="w"> </span><span class="m">10</span>.0,
<span class="w">            </span><span class="s2">&quot;expiration&quot;</span>:<span class="w"> </span><span class="m">0</span>.0,
<span class="w">            </span><span class="s2">&quot;members&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                </span><span class="s2">&quot;file:/volumes/_nogroup/sub1/b1fcce76-3418-42dd-aa76-f9076d047dd3&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                    </span><span class="s2">&quot;excluded&quot;</span>:<span class="w"> </span>false,
<span class="w">                    </span><span class="s2">&quot;state&quot;</span>:<span class="w"> </span><span class="o">{</span>
<span class="w">                        </span><span class="s2">&quot;name&quot;</span>:<span class="w"> </span><span class="s2">&quot;QUIESCING&quot;</span>,
<span class="w">                        </span><span class="s2">&quot;age&quot;</span>:<span class="w"> </span><span class="m">2</span>.0
<span class="w">                    </span><span class="o">}</span>
<span class="w">                </span><span class="o">}</span>
<span class="w">            </span><span class="o">}</span>
<span class="w">        </span><span class="o">}</span>
<span class="w">    </span><span class="o">}</span>
<span class="o">}</span>
Error<span class="w"> </span>EINPROGRESS:
ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>sub1<span class="w"> </span>--timeout<span class="o">=</span><span class="m">10</span><span class="w"> </span>--await-for<span class="o">=</span><span class="m">2</span><span class="w">  </span><span class="m">0</span>.41s<span class="w"> </span>user<span class="w"> </span><span class="m">0</span>.04s<span class="w"> </span>system<span class="w"> </span><span class="m">17</span>%<span class="w"> </span>cpu<span class="w"> </span><span class="m">2</span>.563<span class="w"> </span>total</span>
</pre></div></div><p>（ Ceph 客户端会增加大约 0.5 秒的开销，至少在本地调试集群中如此）</p>
</section>
<section id="quiesce-await-and-expiration">
<h3>静默-等待和过期（ Quiesce-Await and Expiration ）<a class="headerlink" href="#quiesce-await-and-expiration" title="Permalink to this heading"></a></h3>
<p>静默等待有个副作用：它会重置内部过期计时器。可以用看门狗方式处理长期运行的多步进程，在 IO 暂停状态下，通过重复等待（ <code class="docutils literal notranslate"><span class="pre">--await</span></code> ）已静默（ <cite>QUIESCED</cite> ）的集合。看下面的示例脚本：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2"><span class="nb">set</span><span class="w"> </span>-e<span class="w">   </span><span class="c1"># (1)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>sub1<span class="w"> </span>sub2<span class="w"> </span>sub3<span class="w"> </span>--timeout<span class="o">=</span><span class="m">30</span><span class="w"> </span>--expiration<span class="o">=</span><span class="m">10</span><span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--await<span class="w"> </span><span class="c1"># (2)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>create<span class="w"> </span>a<span class="w"> </span>sub1<span class="w"> </span>snap1-sub1<span class="w">  </span><span class="c1"># (3)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--await<span class="w">  </span><span class="c1"># (4)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>create<span class="w"> </span>a<span class="w"> </span>sub2<span class="w"> </span>snap1-sub2<span class="w">  </span><span class="c1"># (3)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--await<span class="w">  </span><span class="c1"># (4)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>create<span class="w"> </span>a<span class="w"> </span>sub3<span class="w"> </span>snap1-sub3<span class="w">  </span><span class="c1"># (3)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--release<span class="w"> </span>--await<span class="w">  </span><span class="c1"># (5)</span></span>
</pre></div></div><div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>本例用任意超时来阐述这一概念。现实中，
这个数值必须根据实际的系统要求和规格谨慎选择。</p>
</div>
<p>脚本的目标是为 3 个子卷拍下一致的快照。
我们首先设置 bash 的 <code class="docutils literal notranslate"><span class="pre">-e</span></code> 选项 <cite>(1)</cite> ，
以便在后续命令返回非零状态码时退出脚本。</p>
<p>我们继续请求三个子卷的 IO 暂停 <cite>(2)</cite> 。我们设置了超时，
允许系统花最多 30 秒时间让所有成员进入静默状态，
并在静默到期和 IO 恢复之前保持静默状态最多 10 秒。
我们还指定了 <code class="docutils literal notranslate"><span class="pre">--await</span></code> ，只有在达到静默状态后才继续下一步。</p>
<p>然后，我们继续使用一组命令对、拍“下一个快照”，并在命令集中调用 <code class="docutils literal notranslate"><span class="pre">--await</span></code> ，
将过期超时时间再延长 10 秒 <cite>(3,4)</cite> 。这种方法为每个快照提供了最多 10 秒的时间，
而且还能在不失去 IO 暂停和保持一致性的情况下，根据需要拍摄任意数量的快照。
如果我们愿意，可以在每次调用了等待时更新过期时间（ <cite>expiration</cite> ）。</p>
<p>如果有快照卡住，需要 10 秒以上才能完成，那么下一次调用 <code class="docutils literal notranslate"><span class="pre">--await</span></code> 时就会返回错误，因为此集合会是过期状态（ <cite>EXPIRED</cite> ），不是可等待状态（ awaitable ）。
这就限制住了不利情况下对应用程序的影响。</p>
<p>我们本可以在 <cite>(2)</cite> 的一开始就把 <cite>expiration</cite> 超时设置为 30 ，
但这意味着一个卡住的快照会让应用程序在这段时间内一直处于等待状态。</p>
</section>
<section id="if-version">
<h3>If Version （判断版本）<a class="headerlink" href="#if-version" title="Permalink to this heading"></a></h3>
<p>有时，仅仅观察到成功的退出或释放还不够。
原因可能是另一个客户端同时更改了这个集合。看这个例子：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>sub1<span class="w"> </span>sub2<span class="w"> </span>sub3<span class="w"> </span>--timeout<span class="o">=</span><span class="m">30</span><span class="w"> </span>--expiration<span class="o">=</span><span class="m">60</span><span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--await<span class="w">  </span><span class="c1"># (1)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>create<span class="w"> </span>a<span class="w"> </span>sub1<span class="w"> </span>snap1-sub1<span class="w">  </span><span class="c1"># (2)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>create<span class="w"> </span>a<span class="w"> </span>sub2<span class="w"> </span>snap1-sub2<span class="w">  </span><span class="c1"># (3)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>subvolume<span class="w"> </span>snapshot<span class="w"> </span>create<span class="w"> </span>a<span class="w"> </span>sub3<span class="w"> </span>snap1-sub3<span class="w">  </span><span class="c1"># (4)</span></span>
<span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--release<span class="w"> </span>--await<span class="w">  </span><span class="c1"># (5)</span></span>
</pre></div></div><p>顺序看起来没问题，释放 <cite>(5)</cite> 也成功完成了。但是，有可能在 sub3 <cite>(4)</cite> 的快照拍下之前，另一个会话把 sub3 从集合中排除掉了，恢复了它的 IO 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--exclude<span class="w"> </span>sub3</span>
</pre></div></div><p>由于从集合中删除成员不会影响它的 <cite>QUIESCED</cite> 状态，因此 release 命令 <cite>(5)</cite>
没理由失败。它会确认 sub1 和 sub2 这两个未被排除的成员，并报告成功。</p>
<p>为了解决这个问题或此类问题， quiesce 命令支持乐观并发模式。
要激活该模式，需要传递一个 <code class="docutils literal notranslate"><span class="pre">--if-version=&lt;version&gt;</span></code> 参数，
该参数将与集合的 db 版本进行比较，只有当数值匹配时，操作才会继续。
否则，命令不会执行，并返回状态 <code class="docutils literal notranslate"><span class="pre">ESTALE</span></code> 。</p>
<p>要知道一个集合应该期待的版本很容易，因为每条修改集合的命令都会在 stdout 上返回该集合，不管退出状态如何。在上面的示例中，我们可以看到，
每个集合都带一个 <code class="docutils literal notranslate"><span class="pre">&quot;version&quot;</span></code> 属性，每次修改这个集合，
无论是用户显式修改还是隐式修改，这个属性都会更新。</p>
<p>在本小节开头的示例中，初始 quiesce 命令 <cite>(1)</cite> 会返回新创建的集合，
其 id 为 <code class="docutils literal notranslate"><span class="pre">&quot;snapshots&quot;</span></code> ，版本为 13 。
由于用命令 <cite>(2,3,4)</cite> 拍快照时，我们不希望对集合做任何更改，
因此 release （释放）命令 <cite>(5)</cite> 可能是这样的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;snapshots&quot;</span><span class="w"> </span>--release<span class="w"> </span>--await<span class="w"> </span>--if-version<span class="o">=</span><span class="m">13</span><span class="w"> </span><span class="c1"># (5)</span></span>
</pre></div></div><p>这样， release 命令的结果就会是 <code class="docutils literal notranslate"><span class="pre">ESTALE</span></code> ，而不是 0 ，
我们就能知道 quiesce 集合不对劲，拍下的快照也可能不一致。</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>当 <code class="docutils literal notranslate"><span class="pre">--if-version</span></code> 和命令返回 <code class="docutils literal notranslate"><span class="pre">ESTALE</span></code> 时，
请求的操作<strong>不会</strong>执行。这意味着脚本可能还需要对这个集合执行某些无条件命令（ unconditional command ），以根据要求调整其状态。</p>
</div>
<p>对于自动化软件来说， <code class="docutils literal notranslate"><span class="pre">--if-version</span></code> 参数还有另一种用途。
正如我们前面所讨论的，可以用指定集合 id 创建个新的 quiesce 集合。
像用于 Kubernetes 的 CSI 这样的驱动程序，可以用其内部请求 ID ，
这样就无需维护与 quiesce 集合 ID 的额外映射。不过，为了保证唯一性，
驱动程序可能需要验证该集合确实是新的。为此，可以用 <code class="docutils literal notranslate"><span class="pre">if-version=0</span></code> ，
而且只有当数据库中没有这个集合 id 时，才会创建新集合。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt2">ceph<span class="w"> </span>fs<span class="w"> </span>quiesce<span class="w"> </span>fs1<span class="w"> </span>sub1<span class="w"> </span>sub2<span class="w"> </span>sub3<span class="w"> </span>--set-id<span class="o">=</span><span class="s2">&quot;external-id&quot;</span><span class="w"> </span>--if-version<span class="o">=</span><span class="m">0</span></span>
</pre></div></div></section>
</section>
<section id="volumes">
<span id="disabling-volumes-plugin"></span><h2>禁用 volumes 插件<a class="headerlink" href="#volumes" title="Permalink to this heading"></a></h2>
<p>默认情况下， volumes 插件是启用的、且设置成了 <code class="docutils literal notranslate"><span class="pre">always</span> <span class="pre">on</span></code> （始终打开）。
但在某些情况下，禁用它可能更合适。例如，当 CephFS 处于降级状态时，
卷插件命令可能会堆积在 MGR 中，而不是顺利执行。
这最终会导致策略节流启动，而且 MGR 变得反应迟钝。</p>
<p>在这种情况下，可以禁用 volumes 插件，即便它在 MGR 中是始终开启的
（ <code class="docutils literal notranslate"><span class="pre">always</span> <span class="pre">on</span></code> ）模块。要禁用，可执行
<code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">mgr</span> <span class="pre">module</span> <span class="pre">disable</span> <span class="pre">volumes</span> <span class="pre">--yes-i-really-mean-it</span></code> 命令。
注意，此命令会禁用 volume 插件的操作并删除 volumes 插件的命令，
因为它要禁用 Ceph 集群上、所有通过这个插件访问的 CephFS 服务。</p>
<p>在采取类似这样激烈的措施之前，最好先尝试不那么激烈的措施，
然后评估文件系统体验是否因此得到改善。类似措施比如，
禁用 volumes 插件启动的、用于克隆和清除垃圾的异步线程。</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../app-best-practices/" class="btn btn-neutral float-left" title="分布式文件系统之上的应用程序最佳实践" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../quota/" class="btn btn-neutral float-right" title="CephFS 配额管理" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>